/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: user
 * Date: 2023-11-07
 * Time: 18:15
 */
class Animal {
    public String name;
    public int age;

    /*public Animal() {
        System.out.println("Animal()");
    }*/

    static {
        System.out.println("Animal::static{}");
    }

    {
        System.out.println("Animal::{  }");
    }

    public Animal(String name, int age) {
        this.name = name;
        this.age = age;
        System.out.println("Animal(String name, int age)");
    }

    public void eat() {
        System.out.println(this.name+"正在吃.....");
    }
}

class Dog extends Animal {

    public String color;
    /* public Dog() {
         //super();
         System.out.println("Dog()");
     }*/
    static {
        System.out.println("Dog::static{}");
    }

    {
        System.out.println("Dog::{  }");
    }

    public Dog(String name,int age,String color) {
        //调用父类的 带有2个参数的构造方法 来初始化父类当中成员 必须在第一行 所以，super()和this() 是不能同时存在的
        super(name,age);
        this.color = color;

        System.out.println("Dog(String name,int age,String color)");
    }

    public void barks() {
        System.out.println(this.name+" 正在叫.....");
    }
}

class Cat extends Animal{

    public Cat() {
        super("咪咪",10);
    }


    public void miaomiao() {
        System.out.println(this.name+" 正在喵喵叫....");
    }
}

public class Test {

    public static void main(String[] args) {
        Dog dog = new Dog("旺财",10,"白色");
        System.out.println("=======");
        Dog dog2 = new Dog("旺财",10,"白色");

    }
    public static void main1(String[] args) {
        //Dog dog = new Dog();
        Dog dog = new Dog("旺财",10,"白色");
        dog.eat();

        /*Cat cat = new Cat();
        cat.eat();*/

    }
}
